<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <title>树形菜单</title>

  <style>
    ul,
    li {
      margin: 0px;
      padding: 0px;
      list-style: none;
    }

    a {
      text-decoration: none;
      color: #222;
    }

    .tree {
      width: 300px;
    }

    .tree .option {
      width: 100%;
      cursor: pointer;
    }

    .tree .option p span {
      font-weight: bold;
    }

    .tree .option.active p span {
      color: #09f;
    }

    .tree .option p {
      box-sizing: border-box;
      width: 100%;
      font-size: 16px;
      line-height: 46px;
      color: #222222;
      display: flex;
      justify-content: space-between;
      padding-right: 34px;
    }

    .tree .option p .iconfont {
      font-size: 12px;
    }

    .tree .option .tree-two {
      width: 100%;
      height: 0px;
      overflow: hidden;
    }

    .tree .option .tree-two .item {
      width: 100%;
    }

    .tree .option .tree-two .item a {
      box-sizing: border-box;
      padding-left: 2em;
      display: inline-block;
      width: 100%;
      height: 36px;
      line-height: 36px;
      font-size: 16px;
    }

    .tree .option .tree-two .item.active a {
      background-color: #E6F7FF;
      border-right: 4px solid #09f;
      color: #09f;
    }
  </style>
</head>

<body>
  <ul class="tree">
    <li class="option active">
      <p><span>一级标题</span><i class="iconfont icon-xia"></i></p>
      <ul class="tree-two">
        <li class="item"><a href="javascript:;">二级标题</a></li>
        <li class="item"><a href="javascript:;">二级标题</a></li>
        <li class="item"><a href="javascript:;">二级标题</a></li>
      </ul>
    </li>
    <li class="option">
      <p><span>一级标题</span><i class="iconfont icon-xia"></i></p>
      <ul class="tree-two">
        <li class="item"><a href="javascript:;">二级标题</a></li>
        <li class="item"><a href="javascript:;">二级标题</a></li>
        <li class="item"><a href="javascript:;">二级标题</a></li>
      </ul>
    </li>
    <li class="option">
      <p><span>一级标题</span><i class="iconfont icon-xia"></i></p>
      <ul class="tree-two">
        <li class="item"><a href="javascript:;">二级标题</a></li>
        <li class="item"><a href="javascript:;">二级标题</a></li>
      </ul>
    </li>
  </ul>



  <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js"></script>
  <script src="./index.js"></script>
</body>

</html>